package com.syni.mdd.sjb.community.base.controller;

import com.syni.mdd.sjb.community.base.service.SjbChatCountService;
import com.syni.mdd.sjb.community.base.service.SjbUserCountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author wangbaitao
 * @version 1.0.0
 * <h>首页统计数据获取接口</h>
 * @Date 2021/3/4
 **/
@RestController
@RequestMapping("home")
public class SjbQywxHomeDataController {
    @Autowired
    private SjbUserCountService sjbUserCountService;
    @Autowired
    private SjbChatCountService sjbChatCountService;

    /**
     * 获取上一日的统计数据
     *
     * @return 查询结果
     */
    @GetMapping("getUserCount")
    public Map<String, Object> getUserCount(@RequestParam("corpId") String corpId) {
        return sjbUserCountService.getUserCount(corpId);
    }

    /**
     * 获取日期区间的统计i数据
     *
     * @param corpId    企业id
     * @param beginDate 开始日期
     * @param endDate   结束日期
     * @return 查询结果
     */
    @GetMapping("getUserCountByDate")
    public Map<String, Object> getUserCountByDate(@RequestParam("corpId") String corpId,
                                                  @RequestParam("beginDate") String beginDate,
                                                  @RequestParam("endDate") String endDate) {
        return sjbUserCountService.getUserCountByDate(corpId, beginDate, endDate);
    }

    /**
     * 获取上一日的群聊统计数据
     *
     * @return 查询结果
     */
    @GetMapping("getChatCount")
    public Map<String, Object> getChatCount(@RequestParam("corpId") String corpId) {
        return sjbChatCountService.getChatCount(corpId);
    }

    /**
     * 获取日期区间的统计i数据
     *
     * @param corpId    企业id
     * @param beginDate 开始日期
     * @param endDate   结束日期
     * @return 查询结果
     */
    @GetMapping("getChatCountByDate")
    public Map<String, Object> getChatCountByDate(@RequestParam("corpId") String corpId,
                                                  @RequestParam("beginDate") String beginDate,
                                                  @RequestParam("endDate") String endDate) {
        return sjbChatCountService.getChatCountByDate(corpId, beginDate, endDate);
    }
}
